package com.xzh.service.impl;

import com.xzh.dao.ReviewsMapper;
import com.xzh.model.Reviews;
import com.xzh.model.search.ReviewDao;
import com.xzh.service.ReviewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReviewsServiceImpl implements ReviewsService {

    private ReviewsMapper reviewsMapper;
    @Autowired
    public void setReviewsMapper(ReviewsMapper reviewsMapper) {
        this.reviewsMapper = reviewsMapper;
    }

    @Override
    public List<Reviews> selectList() {
        return reviewsMapper.selectListWithNames();
    }

    @Override
    public boolean save(Reviews reviews) {
        return reviewsMapper.insert(reviews) > 0;
    }

    @Override
    public boolean removeById(Integer id) {
        return reviewsMapper.deleteById(id) > 0;
    }

    @Override
    public int updateById(Reviews reviews) {
        return reviewsMapper.updateById(reviews);
    }

    @Override
    public Reviews selectById(Integer id) {
        return reviewsMapper.selectById(id);
    }

    @Override
    public boolean saveList(ReviewDao reviewDao) {
        return reviewsMapper.save(reviewDao);
    }

    @Override
    public List<Map<String, Object>> statistics() {
        return reviewsMapper.statistics();
    }
}
